local jiaofeng = fk.CreateSkill{
    name = "lingling__jiaofeng",
}
Fk:loadTranslationTable{
    ["lingling__jiaofeng"] = "骄凤",
    [":lingling__jiaofeng"] = "每回合限一次，当一名角色手牌变为与你相同时，你可以令其摸或弃置一张牌。",
    ["#lingling__jiaofeng-choose"] = "是否发动 骄凤，令 %dest 摸或弃置一张牌？",
}
jiaofeng:addEffect(fk.AfterCardsMove,{
    anim_type = "control",
    can_trigger = function (self, event, target, player, data)
        if player:hasSkill(jiaofeng.name) and player:usedSkillTimes(jiaofeng.name,Player.HistoryTurn) == 0 then
            for _, move in ipairs(data) do
                if move.from and move.from:getHandcardNum() == player:getHandcardNum() then
                    for _, info in ipairs(move.moveInfo) do
                        if info.fromArea == Card.PlayerHand then
                            return true
                        end
                    end
                end
                if move.to and move.to:getHandcardNum() == player:getHandcardNum() and move.toArea == Card.PlayerHand then
                    return true
                end
            end
        end
    end,
    on_trigger = function (self, event, target, player, data)
        event:setSkillData(self, "cancel_cost", true)
        local tos = {}
        for _, move in ipairs(data) do
            if move.from and move.from:getHandcardNum() == player:getHandcardNum() then
                for _, info in ipairs(move.moveInfo) do
                    if info.fromArea == Card.PlayerHand then
                        table.insertIfNeed(tos,move.from)
                    end
                end
            end
            if move.to and move.to:getHandcardNum() == player:getHandcardNum() and move.toArea == Card.PlayerHand then
                table.insertIfNeed(tos,move.to)
            end
        end
        for _, tp in ipairs(tos) do
            if event:getSkillData(self, "cancel_cost") then
                event:setCostData(self,{tos = {tp}})
                self:doCost(event, target, player, data)
            end
        end
        event:setSkillData(self, "cancel_cost", true)
    end,
    on_cost = function (self, event, target, player, data)
        local room = player.room
        local to = event:getCostData(self).tos[1]
        local choice = room:askToChoice(player,{
            choices = {"draw1","discard1","Cancel"},
            prompt = "#lingling__jiaofeng-choose::"..to.id,
            skill_name = jiaofeng.name,
        })
        if choice ~= "Cancel" then
            event:setCostData(self,{tos = {to}, choice = choice})
            event:setSkillData(self, "cancel_cost", false)
            return true
        end
    end,
    on_use = function (self, event, target, player, data)
        local room = player.room
        local to = event:getCostData(self).tos[1]
        local choice = event:getCostData(self).choice
        if choice == "draw1" then
            to:drawCards(1,jiaofeng.name)
        else
            room:askToDiscard(to,{
                max_num = 1,
                min_num = 1,
                include_equip = true,
                pattern = ".",
                cancelable = false,
                skill_name = jiaofeng.name,
            })
        end
    end,
})
return jiaofeng